<?php

class mySqlConnect {
      protected $db_user;
	protected $db_password;
	protected $host;
	protected $port;
	protected $database;
	protected $linkDB;
	protected $connected = FALSE;

  	public function __construct()
  	{
		$this->db_user = 'root';
		$this->db_password = '';
		$this->host = 'localhost';
		$this->port = '3306';
		$this->database = 'project';

		$this->linkDB = mysqli_connect($this->host, $this->db_user, $this->db_password, $this->database);
		if (!$this->linkDB) {
			die( "Could not connect to database </body></html>" );
    		//header('Location:' .$domainName. 'systemError/?errorCode=DB');
    		exit;
		} else {
			//mysqli_select_db( $this->database, $this->linkDB);
			$this->connected = TRUE;
		}
   	}

    public static function isConnected()
  	{
    	return MySqlConnect::connected;
  	}

   	//Function that closes database connection
	public function closeDB(){
        if ($this->linkDB) {
	        mysqli_close($this->linkDB);
	     	$this->connected = FALSE;
        }
	}

	# GETTER
	public function getConnected() {return $this->connected;}
	public function getLinkDB() {return $this->linkDB;}

}
?>
